//
// DocumentView.cs
//
// Author: 
//  Fredy Ramirez <framirez@pacificcoolwave.com>
//
// Copyright (C) 2011 Fredy Ramirez (http://www.pacificcoolwave.com)
//
//  Creation date: Aug 31, 2011
//  Last modification: 

/*
The MIT License

Copyright (C) 2011 Fredy Ramirez (http://www.pacificcoolwave.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
 */

using System;
using Gtk;

namespace Pcw.PcwTextEditor.PcwDocument
{
	/// <summary>
	/// A basic document view class. All views must derive from this.
	/// </summary>
	public class DocumentView : VBox
	{
		private string name;
		private string label;
		private Widget widget;
		private Document document;
		
		private HBox h_top;
		private HBox h_botton;
		private HBox h_left;
		private HBox h_right;
		
		/// <summary>
		/// Used for views when rise events.
		/// </summary>
		/// <param name="sender">
		///   A <see cref="DocumentView"/> object representing the view which rised the event.
		/// </param>
		public delegate void DocumentViewEventHandler(DocumentView sender);

		/// <summary>
		/// The name of View. It must be unique in a document view array.
		/// </summary>
		public new string Name {
			get {
				return name;
			}
		}

		/// <summary>
		/// Label to show in the tab.
		/// </summary>
		public string Label {
			get {
				return label;
			}
		}		

		/// <summary>
		/// The content widget object of the view (Ex: Gtk.TextView object).
		/// </summary>
		public Widget GtkWidget {
			get {
				return widget;
			}
		}

		/// <summary>
		/// The Document object which contains the view.
		/// </summary>		
		public Document ViewDocument {
			get {
				return document;
			}
		}
		
		public HBox BoxTop {
			get {
				return h_top;
			}
		}
		
		public HBox BoxBotton {
			get {
				return h_botton;
			}
		}
		
		public HBox BoxLeft {
			get {
				return h_left;
			}
		}
		
		public HBox BoxRight {
			get {
				return h_right;
			}
		}
		
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="viewName">
		///   The <see cref="string"/> view name.
		/// </param>
		/// <param name="viewLabel">
		///   The <see cref="string"/> view tab label.
		/// </param>
		/// <param name="viewContent">
		///   The <see cref="Gtk.Widget"/> content object.
		/// </param>
		/// <param name="viewDocument">
		///   The <see cref="Document"/> that contains this view.
		/// </param>
		public DocumentView (string viewName, string viewLabel, Widget viewContent, 
		                     Document viewDocument) : base(false,0)
		{
			name = viewName;
			label = viewLabel;
			document = viewDocument;
			widget = viewContent;
			
			h_top = new HBox(false,0);
			h_botton = new HBox(false,0);
			h_left = new HBox(false,0);
			h_right = new HBox(false,0);			
			
			ScrolledWindow sw = new ScrolledWindow();			
			sw.SetPolicy (Gtk.PolicyType.Automatic, Gtk.PolicyType.Automatic);
			sw.ShadowType = ShadowType.In;
			sw.Add (viewContent);

			HBox hCenter = new HBox(false,0);
			hCenter.PackStart(h_left,false,false,0);
			hCenter.PackStart(sw,true,true,0);
			hCenter.PackStart(h_right,false,false,0);
			
			PackStart(h_top,false,false,0);
			PackStart(hCenter,true,true,0);
			PackStart(h_botton,false,false,0);
		}
		
	}
}

